package constants.enums;

/**
 * 结果状态码及信息
 */
public enum Result {
	SUCCESS(1, "成功"),
	FAIL(-1,"失败")

	;

	private Integer code;
	private String msg;

	private Result(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public static String getMsgByCode(Integer code) {
		String msg = "";
		Result[] array = Result.values();
		for (Result obj : array) {
			if (code.equals(obj.code)) {
				msg = obj.msg;
				break;
			}
		}
		return msg;
	}
}
